package com.csii.activiti.server.core.variable.discover.impl;

import cn.hutool.core.collection.CollUtil;
import com.csii.activiti.server.abstraction.service.ActUserService;
import com.csii.activiti.server.core.constant.FlowNodeVariableTypeConstant;
import com.csii.activiti.server.core.entity.ActFlowNode;
import com.csii.activiti.server.core.variable.discover.ActVariableProcessorDiscover;
import org.activiti.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Set;

@Component
public class ActFlowOneselfVariableProcessor implements ActVariableProcessorDiscover {

    @Autowired
    private ActUserService actUserService;

    @Override
    public String getVariableName() {
        return "发起人自己";
    }

    @Override
    public String getVariableType() {
        return FlowNodeVariableTypeConstant.ONESELF;
    }

    @Override
    public boolean needManyPeopleReview() {
        return false;
    }

    @Override
    public boolean needEmptyProcessing() {
        return false;
    }

    @Override
    public int order() {
        return 2;
    }

    @Override
    public Set<String> getUsernames(ActFlowNode actFlowNode, String executionId, ExecutionEntityImpl processInstance) {
        String startUserId = processInstance.getStartUserId();
        if (startUserId == null){
            return null;
        }
        return CollUtil.newHashSet(startUserId);
    }
}
